//构造函数模式定义对象
function Animal(weight){

    this.weight = weight;

    this.cry = function () {

    }

    this.eat = function () {

    }

    this.weightChange = function (num) {
        switch (num) {
            case 1:
                this.weight += 10;
                break;
            case 2:
                this.weight -= 10;
                break;
            case 3:
                this.weight -= 5;
        }
    }

}

function Sheep() {
    this.animal = Animal;
    this.animal(100);
    delete this.animal;

    this.cry = function () {
        alert("mie....")
        this.weightChange(3);
    }

    this.eat = function (food) {
        if(food.toString().includes("grass")){
            this.weightChange(1);
        }else {
            this.weightChange(2);
        }
    }
}

function Tiger() {
    this.animal = Animal;
    this.animal(200);
    delete this.animal;

    this.cry = function () {
        alert("wow!!!")
        this.weightChange(3);
    }

    this.eat = function (food) {
        if(food.toString().includes("meat")){
            this.weightChange(1);
        }else {
            this.weightChange(2);
        }
    }
}
